package com.ytjj.qmyx.supplychain.mapper;

import com.ytjj.qmyx.supplychain.common.model.CountryInfoVO;
import com.ytjj.qmyx.supplychain.common.model.ProductSpecStockWarningVO;
import com.ytjj.qmyx.supplychain.common.model.request.GoodsRequest;
import com.ytjj.qmyx.supplychain.common.model.request.ProductRequest;
import com.ytjj.qmyx.supplychain.common.model.request.ProductSelectRequest;
import com.ytjj.qmyx.supplychain.common.model.response.*;
import com.ytjj.qmyx.supplychain.mapper.entity.YxBankerStoreAddress;
import com.ytjj.qmyx.supplychain.mapper.entity.YxProduct;
import com.ytjj.qmyx.supplychain.mapper.entity.YxProductCategory;
import com.ytjj.qmyx.supplychain.mapper.entity.YxShopInfo;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Set;

public interface ProductMapper extends Mapper<YxProduct> {
    List<SupplyProductListResponse> getProductNotIncludReceived(ProductRequest request);

    List<SupplyProductListResponse> selectSupplyProductAll(ProductRequest request);

    List<ProductSkuKeyResponse> findSku(Integer id);

    List<ProductImgResponse> findImg(@Param("productId") Integer productId, @Param("type") String type);

    List<ProductSpecResponse> findSpec(Integer id);

    FreightTemplateResponse findFreight(Integer id);

    List<ProductLabelVO> findProductLabel(Integer id);

    ProductSelectDetailResponse findProductSelectDetail(Integer id);

    List<ProductSelectDetailResponse> findProductSelectDetailByIds(@Param("ids") List<Integer> ids);

    List<ProductSelectDetailResponse> findProductSelectDetailByBankerProductIds(@Param("ids") List<Integer> ids);

    List<ProductSelectResponse> findProduceSelect(ProductSelectRequest request);

    Integer getZeroCount(Integer bankerId);

    void deleteImg(Integer id);

    void saveImg(@Param("img") List<ProductImgResponse> img);

    void updateSpecInfoApp(ProductSpecResponse productSpecResponse);

    void updateGoodsNew(GoodsRequest goodsRequest);

    Integer isExists(Integer bankerProductId);

    void updateCategoryId(@Param("id") Integer id,
                          @Param("topCategoryId") Integer topCategoryId,
                          @Param("categoryId") Integer categoryId,
                          @Param("bottomCategoryId") Integer bottomCategoryId,
                          @Param("appraisalType") Integer appraisalType
    );

    int updateProductStatusByIds(@Param("ids") List<Integer> ids, @Param("status") Integer status, @Param("outOfSelection") String outOfSelection);

    Integer getAddressId(Integer productId);

    YxBankerStoreAddress getAddress(Integer addressId);

    List<YxBankerStoreAddress> getAddressForMap(@Param("addressIds") Set<Integer> addressIds);

    /**
     * 根据供应商信息id获取供应商
     */
    List<BankerResponse> selectBankerMsgByBankerId(@Param("bankerIdList") List<Integer> bankerIdList);

    List<BankerProductQueryVo> getBankerProductIdByIds(@Param("ids") List<Integer> ids);

    List<YxProductCategory> selectCategoryById(@Param("topCategoryIds") List<Integer> topCategoryIds);

    void updateBrandByBrandId(Integer id);

    List<YxShopInfo> selectShopINfoByShopIds();

    List<ProductSpecStockWarningVO> selectByStatus(@Param("list") List<Integer> supplySpecIds);

    List<ProductSpecStockWarningVO> selectByStockWarning(List<Integer> supplySpecIds);

    Integer updateInfoImgById(@Param("id") Integer id,@Param("infoImgFinal") String infoImgFinal);

    List<CountryInfoVO> findCountryAll();

    List<YxProduct> selectByProductIds(@Param("list") List<Integer> productIds);

    /**
     * 批量修改分类
     * @param supplyProductIds
     * @param topCategoryId
     * @param categoryId
     * @param bottomCategoryId
     */
    void updateCategoryIdByIds(@Param("supplyProductIds") List<Integer> supplyProductIds,
                               @Param("topCategoryId") Integer topCategoryId,
                               @Param("categoryId") Integer categoryId,
                               @Param("bottomCategoryId") Integer bottomCategoryId);


    /**
     * 获取商品详情
     */
    List<YxProduct> getProductInfoByIds(@Param("ids") List<Integer> ids);

    /**
     * 更新商品库存字段
     * @param id 商品id
     * @param type 类型 sub:减 add:加
     * @param num
     * @return Integer
     */
    Integer updateProductStockById(Integer id,String type,Integer num);
}
